package com.jiyun.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.jiyun.mapper.ActivityMapper;
import com.jiyun.pojo.Activity;
import com.jiyun.service.ActivityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ActivityServiceImpl implements ActivityService {
    @Autowired
    private ActivityMapper activityMapper;

    @Override
    public PageInfo<Activity> findAll(Activity activity, Integer pageNo, Integer pageSize) {
        PageHelper.startPage(pageNo,pageSize);
        List<Activity> activityList = activityMapper.findAll(activity);


        PageInfo<Activity> pageInfo = new PageInfo<>(activityList);
        return pageInfo;
    }

    @Override
    public void delete(Integer id) {
        activityMapper.delete(id);
    }

    @Override
    public void add(Activity activity) {
        activityMapper.add(activity);
    }

    @Override
    public Activity findById(Integer id) {
        return activityMapper.findById(id);
    }

    @Override
    public void update(Activity activity) {
        activityMapper.update(activity);
    }
}
